function []=cashFlow(marketIn, aircraftIn)

% mercado.inflation=[2.3 2.4 2.4 2.4 2.4 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5 2.5]/100;
% mercado.years=2013:2028;
% mercado.optimisticSells=[0 0 0 0 0 37 62 99 111 136 136 86 111 136 148 173];
% mercado.realisticSells=[0 0 0 0 0 31 51 82 93 113 113 72 93 113 123 144];
% mercado.pessimisticSells=[0 0 0 0 0 22 36 58 65 79 79 50 65 79 86 101];
% aviao.nbAircrafts=1000; %number of aircrafts
% aviao.price=5e6; %market price
% aviao.costs.unitCost

%% Sells
figure
bar(marketIn.years,[marketIn.optimisticSells;marketIn.realisticSells;marketIn.pessimisticSells]')
title('Sells')

%% Cash Flow
margin=aircraftIn.price-aircraftIn.costs.cMan/aircraftIn.nbAircrafts;

inflationSerie=cumprod(1+marketIn.inflation);
inflationRdte=inflationSerie(1,1:5);
inflationManufacturing=inflationSerie(1,6:16);

development=aircraftIn.costs.cAedD/5;
development=[development aircraftIn.costs.cAedD/5+aircraftIn.costs.cStD/3];
development=[development aircraftIn.costs.cAedD/5+aircraftIn.costs.cStD/3];
development=[development aircraftIn.costs.cAedD/5+aircraftIn.costs.cStD/3+aircraftIn.costs.prototypes/2+aircraftIn.costs.cFtoD/2];
development=[development aircraftIn.costs.cAedD/5+aircraftIn.costs.prototypes/2+aircraftIn.costs.cFtoD/2+aircraftIn.costs.cFinD];

series=margin.*inflationManufacturing.*marketIn.pessimisticSells(1,6:16);

cashflow=[-development.*inflationRdte series];
figure
bar(marketIn.years,cashflow')

figure
bar(marketIn.years,cumsum(cashflow))
xlabel('Year');ylabel('USD');title('Cash Flow');
PresentVal = teste(cashflow, 0.025)
TIR=calculairr(cashflow)*2/3